"use strict";
cc._RF.push(module, '03e42oEN+VKha6DWdIwBq9D', 'AddDestokPage');
// scripts/Game/Page/AddDestokPage.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameConfig_1 = require("../../engines/configs/gameConfig");
var gameEngine_1 = require("../../engines/gameEngine");
var userInterface_1 = require("../../engines/services/userContent/userInterface");
var MainRoot_1 = require("../MainRoot");
//电子邮件puhalskijsemen@gmail.com
//源码网站 开vpn全局模式打开 http://web3incubators.com/
//电报https://t.me/gamecode999
//网页客服 http://web3incubators.com/kefu.html
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, menu = _a.menu, disallowMultiple = _a.disallowMultiple;
var AddDestokPage = /** @class */ (function (_super) {
    __extends(AddDestokPage, _super);
    function AddDestokPage() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.FirstKey = "get-First-Add";
        _this.rewardNum = null;
        _this.tt = null;
        return _this;
    }
    AddDestokPage.prototype.onLoad = function () {
        this.rewardNum.string = gameConfig_1.default.ADD_ONCE_POWER.toString();
        this.tt = window['tt'];
        //字节跳动 字节跳动lite 和西瓜拒审 关闭
        if (!MainRoot_1.default.isShortcutOpen()) {
            this.node.destroy();
        }
    };
    AddDestokPage.prototype.OnAddBtn = function () {
        gameEngine_1.managers().soundMgr.playSound("mainSound/anNiu");
        console.info("添加快捷方式 onBtnMe");
        // O1HD.getModules().uiControlModule.showMessageBox("添加失败");
        var self = this;
        if (this.tt) {
            console.info("添加快捷方式AddDestokPage");
            this.tt.addShortcut({
                success: function (res) {
                    var key = gameEngine_1.default.getServices().localStorageSrv.getStorage(self.FirstKey);
                    if (key && Number(key) == 1) {
                        console.info("已经添加过快捷方式");
                    }
                    else {
                        console.info("添加快捷方式成功");
                        self.addRewarded();
                        gameEngine_1.default.getServices().localStorageSrv.setStorage(self.FirstKey, 1);
                        gameEngine_1.default.getServices().miniGameSrv.getAppApiInstance().reportAnalytics('addDestok', { addDestok: "添加桌面界面成功" });
                    }
                },
                fail: function (res) {
                    console.info("添加快捷方式失败", res);
                    gameEngine_1.default.getServices().miniGameSrv.getAppApiInstance().reportAnalytics('addDestok', { addDestok: "添加桌面界面失败" });
                    gameEngine_1.default.getModules().uiControlModule.showMessageBox("添加失败");
                }
            });
        }
        else {
            this.addRewarded();
            gameEngine_1.default.getServices().localStorageSrv.setStorage(self.FirstKey, 1);
        }
        this.node.destroy();
    };
    AddDestokPage.prototype.addRewarded = function () {
        gameEngine_1.services().userSrv.addPowerOfVideo();
        gameEngine_1.modules().uiControlModule.showGetRewarded(userInterface_1.REWARD_TYPE.POWER, gameConfig_1.default.ADD_ONCE_POWER, "恭喜");
    };
    AddDestokPage.prototype.onClose = function () {
        gameEngine_1.default.getServices().miniGameSrv.getAppApiInstance().reportAnalytics('addDestok', { addDestok: "添加桌面界面取消" });
        this.node.destroy();
    };
    __decorate([
        property({ type: cc.Label, displayName: "奖励数" })
    ], AddDestokPage.prototype, "rewardNum", void 0);
    AddDestokPage = __decorate([
        ccclass,
        disallowMultiple,
        menu('游戏页面/添加桌面快捷')
    ], AddDestokPage);
    return AddDestokPage;
}(cc.Component));
exports.default = AddDestokPage;

cc._RF.pop();